<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <jd-header></jd-header>
      <jd-body></jd-body>
    </div>

    <script src="../Vue.js"></script>
    <script>
      // 局部创建组件
      // 这个对象的内容和全局创建组件的第二个参数完全相同

      // 取名只能是大驼峰
      const JdHeader = {
        data() {
          return {
            title: "京东",
          };
        },
        template: `
          <header>{{ title }}头部</header>
        `,
      };

      const JdButton = {
        template: `
          <button>btn</button>
        `,
      };

      const JdBody = {
        template: `
          <main>京东内容 - <jd-button></jd-button></main>
        `,
        components: {
          JdButton,
        },
      };

      new Vue({
        el: "#app",
        data: {},
        // 局部创建的组件时需要注册的
        // 注册在父组件
        components: {
          // JdHeader: JdHeader,
          JdHeader,
          JdBody,
        },
      });
    </script>
  </body>
</html>
